package com.starview.star.compiler.canonical;

import com.starview.platform.data.type.Location;
import com.starview.platform.data.type.StandardTypes;
import com.starview.star.compiler.util.PrettyPrintDisplay;

@SuppressWarnings("serial")
public class ProcedureCallAction extends Action
{
  private final IContentExpression proc;
  private final IContentExpression args[];

  public ProcedureCallAction(Location loc, IContentExpression proc, IContentExpression... args)
  {
    super(loc, StandardTypes.unitType);
    this.proc = proc;
    this.args = args;
  }

  @Override
  public void prettyPrint(PrettyPrintDisplay disp)
  {
    proc.prettyPrint(disp);
    disp.append("(");
    disp.prettyPrint(args, ",");
    disp.append(")");
  }

  public IContentExpression getProc()
  {
    return proc;
  }

  public IContentExpression[] getArgs()
  {
    return args;
  }

  public IContentExpression getArg(int ix)
  {
    return args[ix];
  }

  @Override
  public void accept(CanonicalVisitor visitor)
  {
    visitor.visitProcedureCallAction(this);
  }

  @Override
  public void accept(ActionVisitor visitor)
  {
    visitor.visitProcedureCallAction(this);
  }

  @Override
  public <A, E, P, C, D, T> A transform(TransformAction<A, E, P, C, D, T> transform, T context)
  {
    return transform.transformProcedureCallAction(this, context);
  }
}
